using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization;

namespace CSF.Communications.Sdp.ServiceLogic.Exceptions
{
   public class SDPBusinessException : SDPException
    {


      #region Private Members

      private long errorCode;
      private string message;

      #endregion Properties

      #region Public Property

      /// <summary>
      /// Property to retain error code
      /// </summary>
      public long ErrorCode
      {
         get
         {
            return errorCode;
         }
      }

      /// <summary>
      /// User friendly to be set- Overriding Message propertyof base Error 
      /// </summary>
      public override string Message
      {
         get
         {
            return message;
         }
      }

      #endregion Property methods

      #region Constructors

      #region SDPBusinessException
      /// <summary>
      ///   Default Constructor
      /// </summary>
      public SDPBusinessException()
      {
         errorCode = (long)SDPBusinessError.SDPBusinessException;
         base.EventId = (int)SDPBusinessEvent.SDPBusinessException;
			
      }

      #endregion


       #region SDPBusinessException(string)
      /// <summary>
      /// Constructor with two parameter to convert general Exception to
      /// custom Exception UIBusinessException and set custom error message.
      /// </summary>
      /// <param name="description">Custom message that is to be set</param>
      public SDPBusinessException(string description)
      {
         errorCode = (long)SDPBusinessError.SDPBusinessException;
         message = description;
         base.EventId = (int)SDPBusinessEvent.SDPBusinessException;
      }

      #endregion

      #region SDPBusinessException(Exception)
      /// <summary>
      ///   Constructor with one parameter to convert general Exception to
      /// custom Exception UIBusinessException.
      /// </summary>
      /// <param name="sdpUIBusinessException">System Exception that is caught</param>
      public SDPBusinessException(Exception sdpBusinessException)
      {
         errorCode = (long)SDPBusinessError.SDPBusinessException;
         message = sdpBusinessException.Message;
         base.EventId = (int)SDPBusinessEvent.SDPBusinessException;
      }

      #endregion

      #region SDPBusinessException(string,Exception)
      /// <summary>
      /// Constructor with two parameter to convert general Exception to
      /// custom Exception UIBusinessException and set custom error message.
      /// </summary>
      /// <param name="description">Custom message that is to be set</param>
      /// <param name="sdpUIBusinessException">System Exception caught</param>
      public SDPBusinessException(string description, Exception sdpBusinessException)
      {
         errorCode = (long)SDPBusinessError.SDPBusinessException;
         message = description + Environment.NewLine + sdpBusinessException.Message;
         base.EventId = (int)SDPBusinessEvent.SDPBusinessException;
      }

      #endregion

      #region SDPBusinessException(long,string)
      /// <summary>
      /// Constructor with two parameter to convert general Exception to
      /// custom Exception SDPUIHEBusinessException and set custom error message.
      /// </summary>
      /// <param name="businessErrorCode">Custom error code that is to be set</param>
      /// <param name="errorDescription">Custom message that is to be set</param>
      public SDPBusinessException(long businessErrorCode, string errorDescription)
      {
         errorCode = businessErrorCode;
         message = errorDescription + Environment.NewLine;

			string errorText = string.Empty;

         if (Enum.IsDefined(typeof(SDPBusinessError), (SDPBusinessError)errorCode))
         {
            message += ((SDPBusinessError)errorCode).ToString();
				errorText = ((SDPBusinessError)errorCode).ToString();
         }
         else
         {
            message += SDPBusinessError.SDPBusinessException.ToString();
            errorText = SDPBusinessError.SDPBusinessException.ToString();
         }
			SDPBusinessEvent be = (SDPBusinessEvent)Enum.Parse(typeof(SDPBusinessEvent), errorText);
			base.EventId = Convert.ToInt32(be);

      }

      #endregion

      #region SDPBusinessException(SerializationInfo,StreamingContext)
      /// <summary>
      /// Constructor with two parameter to convert general Exception to
      /// custom Exception UIDataException and set custom error message.
      /// </summary>
      /// <param name="SerializationInfo">SerializationInfo</param>
      /// <param name="StreamingContext">StreamingContext</param>
      // deserialization constructor
      public SDPBusinessException(SerializationInfo info, StreamingContext context)
      {
      }

        #endregion
		
      #endregion
   }
 }

